package light.head.model.inv;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Formula;

/**
 * 收据
 * @author yy
 */
@Entity
@Table
public class InvReceipts implements Serializable{
	private static final long serialVersionUID = -1012260650016278110L;
	
	private Integer code;					// 流水号
	private Integer oc;						// 机构编号
	private Byte type;						// 类型(1.收款 2.付款)
	private String dn;						// 单据编号
	private Double price;					// 金额
	private Integer sc;						// 结算方式编号
	private Integer bc;						// 来往商编号
	private Integer ac;						// 账户编号
	private Integer cu;						// 创建人
	private Date ct;						// 创建时间
	private Boolean deleted = false;		// 是否删除
	
	private String on;						// 机构名称
	private String cn;						// 创建人名称
	private String sn;						// 结算方式
	private String bn;						// 来往商
	private String an;						// 账户

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Byte getType() {
		return type;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Column
	public String getDn() {
		return dn;
	}
	@Column
	public Double getPrice() {
		return price;
	}
	@Column
	public Integer getSc() {
		return sc;
	}
	@Column
	public Integer getBc() {
		return bc;
	}
	@Column
	public Integer getAc() {
		return ac;
	}
	@Column(updatable = false, nullable = false)
	public Integer getCu() {
		return cu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	@Formula("(SELECT s.name FROM InvSettlement s WHERE s.code = sc)")
	public String getSn() {
		return sn;
	}
	@Formula("(SELECT b.name FROM InvBusiness b WHERE b.code = bc)")
	public String getBn() {
		return bn;
	}
	@Formula("(SELECT a.card FROM InvAccount a WHERE a.code = ac)")
	public String getAn() {
		return an;
	}
	
	
	
	
	
	
	
	
	
	
	
	public void setOn(String on) {
		this.on = on;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	public void setSn(String sn) {
		this.sn = sn;
	}
	public void setBn(String bn) {
		this.bn = bn;
	}
	public void setAn(String an) {
		this.an = an;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setDn(String dn) {
		this.dn = dn;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	public void setSc(Integer sc) {
		this.sc = sc;
	}
	public void setBc(Integer bc) {
		this.bc = bc;
	}
	public void setAc(Integer ac) {
		this.ac = ac;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setType(Byte type) {
		this.type = type;
	}
	
	
}
